package com.jushu.storbox.constant;


import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * 
 * cloud drive Constant value
 * 
 */
public class Constant {
	

	public final static String LINK_ROLE_VIEW = "viewer";
	public final static String LINK_ROLE_PREVIEW = "previewer";
	public final static String LINK_ROLE_UPLOADER = "uploader";
	public final static String LINK_ROLE_UPLOAD_VIEWER = "uploadAndView";
	
	public final static int FIRST_PAGE_INDEX = 0;
	public final static String ROOT_FOLDER_ID = "0";
	public final static int UPLOAD_TYPE_COMMON = 0;
	public final static int UPLOAD_TYPE_ALBUM = 1;
	
	/** broadcast refresh list ui */
	public final static String REFRESH_APPSTORE_ACTION = "com.huawei.sharedrive.NOTIFY_RESLIST";
	
	public final static String REFRESH_GETFILELIST_ISSUCCESS = "com.huawei.sharedrive.GET_FILE_SUCCESS";
	
	/** broadcast refresh state */
	public final static String REFRESH_ALLFILESTATE_ACTION = "com.huawei.sharedrive.ALLFILESTATE";
	
	/** broadcast share for me  state */
	public final static String STATE_SHARED_FRO_ME = "com.huawei.sharedrive.SHAREDFORMESTATE";

	public final static String SHARE_WITHOUT_LOGIN = "upload_from_share_not_finish";
	
	public final static String FILE_NAME_SEPERATE = "_";

	public final static int MUNIUTE = 60;
	
	public final static int SECOND = 1000;
	
	public final static int MD5BLOCK_KB_SIZE = 256 * 1024;
	
	public final static int MD5BLOCK_B_SIZE = 256;
	
	public final static int MILLIS_OF_MINIUTE = MUNIUTE * SECOND; 
	
	/** Handler create folder */
	public final static int CREATEFOLDER = 10;

	/** Handler move file&folder */
	public final static int MOVE = 11;

	/** Handler delete file&folder */
	public final static int DELETE = 12;

	/** Handler rename file&folder */
	public final static int RENAME = 13;
	

	//no start
	public final static int TRANSLATE_IS_NOTHING = 0;
	//start state
	public final static int TRANSLATE_IS_WAITING = 1;
	public final static int TRANSLATE_IS_STARTED = 2;
	//progress state
	public final static int TRANSLATE_IS_RUNNING = 3;
	public final static int TRANSLATE_IS_STOPED = 4;
	public final static int TRANSLATE_IS_CANCELED = 5;
	//finished state
	public final static int TRANSLATE_IS_FAILURED = 6;
	public final static int TRANSLATE_IS_SUCCESS = 7;
	
	/**
	 *  sqlite update download struts
	 *  
	 * */
	public final static int DOWNLOAD_ISWAITING_UPDATE_DB = 1;
	public final static int DOWNLOAD_ISRUNNING_UPDATE_DB = 2;
	public final static int DOWNLOAD_CANCEL_UPDATE_DB = 4;
	public final static int DOWNLOAD_STOP_UPDATE_DB = 9;
	public final static int DOWNLOAD_SUCCESS_UPDATE_DB = 3;
	public final static int DOWNLOAD_FAIL_UPDATE_DB = 5;
	public final static int DOWNLOAD_NON_UPDATE_DB = 0;
	public final static int DOWNLOAD_CONTENT_NOT_SYNCHRONIZATION = 6;
	public final static int DOWNLOAD_RES_NOEXIST_NORIGHT = 7;
	public final static int DOWNLOAD_RES_NOSPACE = 8;
	
	
	public final static int DOWNLOAD_STATUS_CACHE_DB = 1;
	public final static int DOWNLOAD_STATUS_NOCACHE_DB = 0;
	public final static int DOWNLOAD_STATUS_INODE = 0;
	public final static int DOWNLOAD_STATUS_NOT_INODE = 1;
	

	public final static int SYNC_STATUS_TRUE = 1;
	public final static int SYNC_STATUS_FALSE = 0;
	
	public final static int DOWNLOAD_FAIL_FILEDID_NULL_CODE = -1000;
	public final static int DOWNLOAD_CANCEL_SUCCESS_CODE = -1001;
	public final static int DOWNLOAD_FAIL_EXCEPTION_CODE = -1002;
	public final static int DOWNLOAD_FAIL_CLOSEIO_CODE = -1003;
	public final static int DOWNLOAD_THREAD_ERROR_CODE = -1004;
	public final static int DOWNLOAD_WRITE_FILE_ERROR_CODE = -1005;
	public final static int DOWNLOAD_FAIL_FILE_LARGERTHAN_CACHESIZE = -1006;
	public final static int DOWNLOAD_FAIL_FILE_ASSIGN_CACHESIZE = -1007;
	public final static int SAVE_TO_ONEBOX_fail = 10000;
	
	/**mycloud or shared**/
	public final static int MYCLOUD_GET_FILE_LIST_STATE = 0;
	public final static int SHARED_GET_FILE_LIST_STATE = 1;
	
	/**my file list adapter refresh handler**/
	public final static int CLOUD_ADAPTER_HANDLER_INITUI = 0;
	public final static int CLOUD_ADAPTER_HANDLER_FILEUI = 1;
	public final static int CLOUD_ADAPTER_HANDLER_FILE_ISUPLOAD = 2;
	public final static int CLOUD_ADAPTER_HANDLER_FILE_NOUPLOAD = 3;
	public final static int CLOUD_ADAPTER_HANDLER_FOLDERUI = 4;

	public final static String CLOUD_UPGRADE_STATE = "CLOUD_UPGRADE_STATE";
	
	/**file type**/
	public final static String []IMAGE_TYPE = {".png", ".jpg", ".gif", ".bmp", ".jpeg", ".pg"};//image type
	public final static String []WORD_TYPE = {".doc", ".docx"};//word tpye
	public final static String []PPT_TYPE = {".ppt", ".pptx"};//ppt tpye
	public final static String []EXCEL_TYPE = {".xls",".xlsx"};//excel tpye
	public final static String []PDF_TYPE = {".pdf"};//pdf tpye
	public final static String []RAR_TYPE = {".rar"};
	public final static String []ZIP_TYPE = {".zip"};
	public final static String []MUSIC_TYPE = {".mp3"};
	public final static String []VIDEO_TYPE = {".avi",".rmvb",".mp4", ".mpeg4", ".gpp", ".3gpp2", ".mp2t", ".MP2T", ".mpeg", ".rmvb", ".real",".wma"};
	public final static String []TXT_TYPE = {".txt",".log", ".xml"};
	public final static String []APK_TYPE = {".apk"};
	
	/**
	 * office Type
	 */
	public final static String []DOCUMENT_TYPE = {".doc", ".docx",
											".ppt", ".pptx",
											".xls",".xlsx",
											".pdf",".txt",
											".pps",".ppsx",
											".xlt",".xltx",
											".dot",".dotx"};
	
	/**take photo**/
	public static final int REQUEST_CODE_TAKE_PICTURE = 0x91;
	public static final int REQUEST_PHOTO_RESULT = 0x92;

	public static final long ONE_KB = 1024;
	public static final long ONE_MB = 1048576;
	public static final long ONE_GB = 1073741824;
	public static final int MAX_ALLOWED_VIEW_PICTURE_SIZE = 10 * 1020 * 1024;
	
	public static final int FOLDER = 0;
	public static final int MAX_SHARE_COUNT = 1000;
	public static final String ALL_FILL="";
	
	public static final int APK_NOW_IS_DOWNLOADING = 1;
	public static final int APK_NOT_IN_DOWNLOADING = 2;
	public static final int APK_DOWNLOAD_FAIL = 3;
	
	public static final String UPLOAD_SYNC_WAITING = "waiting";
	public static final String UPLOAD_SYNC_FINISH = "finish";
	public static final String UPLOAD_SYNC_FAIL = "fail";
	
	public static void setShareWithoutLogin(Context context, boolean loginFlag){
		SharedPreferences setting = context.getSharedPreferences(
					ClientConfig.settings, Context.MODE_APPEND);
		Editor settingEdit = setting.edit();
    	settingEdit.putBoolean(Constant.SHARE_WITHOUT_LOGIN, loginFlag);
    	settingEdit.commit();
	}
	
	public static boolean getShareWithoutLogin(Context context){
		SharedPreferences setting = context.getSharedPreferences(
				ClientConfig.settings, Context.MODE_APPEND);
		return setting.getBoolean(Constant.SHARE_WITHOUT_LOGIN,false);
	}
}
